<html>
<body>
<script>

var points = [];
var line;
var lastInterval;

function showTrack(set_Id,startTime,endTime){
    map = buildMap("googleMap");
    var url = "/phone/queryAccountTrack?set_Id="+set_Id+"&startTime="+startTime+"&endTime="+endTime;
  //加载地图坐标信息
    AjaxUtil.ajaxRequest(url, "json", function (data) {
      if(data != null) {
        var positions = data.positions;
        if(positions != null){
            setStartAndEndMarker(positions);
            for(var key in positions) {
              var mapdata = positions[key];
              var x = mapdata.x;
              var y = mapdata.y;
              var point = buildPoint(x,y);
              points.push(point);
            }
         }
      }
    },false);
    showAllPoints(points);
    setLine();
    points = [];
}

/*设置起始点 终止点*/
function setStartAndEndMarker(positions){
    var length = positions.length;
    var startPosition = positions[0];
    var x = startPosition.x;
    var y = startPosition.y;
    var point = buildPoint(x,y);
    var marker = buildMarkerAndLabelByPoint(point,marker_start,"<@spring.message 'phone.analysis.phonesylocation.start' />");

    if(length > 1){
        var endPosition = positions[length-1];
        var x = endPosition.x;
        var y = endPosition.y;
        var point = buildPoint(x,y);
        var marker = buildMarkerAndLabelByPoint(point,marker_end,"<@spring.message 'phone.analysis.phonesylocation.end' />");
    }
}

/*设置icon*/
var lineSymbol = {
  path: 0,
  scale: 8,
  strokeColor: '#393'
};

/*设置轨迹*/
function setLine(){
  line = new google.maps.Polyline({
    path: points,
    icons: [{
      icon: lineSymbol,
      offset: '100%'
    }],
    map: map
  });
  removeInterval(lastInterval);
  animateCircle();
}

/*设置轨迹动画*/
function animateCircle() {
    var count = 0;
    lastInterval = window.setInterval(function() {
      count = (count + 1) % 200;
      var icons = line.get('icons');
      icons[0].offset = (count / 2) + '%';
      line.set('icons', icons);
  }, 20);
}

/*清除轨迹动画*/
function removeInterval(lastInterval){
    if(lastInterval != undefined){
        clearInterval(lastInterval);
    }
}
</script>
</body>
</html>